package com.veryedu.hibernate.hbm.dao.impl;

import java.util.List;

import org.hibernate.Query;

import com.veryedu.hibernate.hbm.dao.TicketsDao;
import com.veryedu.hibernate.hbm.entity.Seat;
import com.veryedu.hibernate.hbm.entity.ShowTime;
import com.veryedu.hibernate.hbm.entity.Tickets;

public class TicketsDaoImpl extends BaseDaoImpl implements TicketsDao {

	@Override
	public List<Tickets> findByShowTimeAndSeat(ShowTime st, Seat seat) {
		List<Tickets> ticketList = null;
		try{
			this.getSession();
			tr = session.beginTransaction();
			String hql = "from Tickets t where t.showTime = :showTime and t.seat = :seat";
			Query query = session.createQuery(hql);
			query.setParameter("showTime", st);
			query.setParameter("seat", seat);
			ticketList = (List<Tickets>) query.list();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			this.closeSession(session);
		}
		return ticketList;
	}

}
